﻿Partial Class Paginas_ListarConvenios
    Inherits System.Web.UI.Page

#Region "Funciones de la Página"
    Public Function OpcionesConvenio(ByVal Activo As String, ByVal Codigo As String) As String
        Dim strHTML As String = ""
        If Activo = "NO" Then
            strHTML = "<img src='img/publicar.gif' style='cursor:pointer;' onClick='ReenviarPag(1," & Codigo.Trim & ");'/>&nbsp;&nbsp;"
            strHTML = strHTML & "<img src='img/editar.gif' style='cursor:pointer;' onClick='ReenviarPag(2," & Codigo.Trim & ");'/>"
        End If
        Return strHTML
    End Function

    Private Sub CargarConvenios()
        Dim miCollect As New Collection
        Dim miNegConv As New dllNegocio.NegConvenios(System.Configuration.ConfigurationManager.AppSettings.Get("SPECBDD"))
        Try
            Session("SeekConvenio") = Me.txtNombreConvenio.Text.Trim
            miCollect = miNegConv.ListarConvenios(0, IIf(Me.txtNombreConvenio.Text.Trim = "", "TODOS", Me.txtNombreConvenio.Text.Trim), 0)
            Me.GrillaResultados.DataSource = miCollect
            Me.GrillaResultados.DataBind()
        Catch ex As Exception
        Finally
            miCollect = Nothing
            miNegConv.Dispose()
            miNegConv = Nothing
        End Try
    End Sub
#End Region

    Protected Sub btnAgregar_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAgregar.Click
        Response.Redirect("mantenerConvenios.aspx?ConvenioID=0")
        Response.End()
    End Sub

    Protected Sub btnBuscar_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnBuscar.Click
        Call CargarConvenios()
    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Page.IsPostBack Then
            If Request.QueryString("PostBack") = "SI" Then
                Me.txtNombreConvenio.Text = Session("SeekConvenio")
                Call CargarConvenios()
            End If
        End If
    End Sub
End Class
